﻿namespace DomainServices.Tools.Pdb.SymStore
{
    using System;
    using System.Diagnostics.SymbolStore;
    using System.Runtime.InteropServices;
    using System.Runtime.InteropServices.ComTypes;
    using System.Text;

    [ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("B4CE6286-2A6B-3712-A3B7-1EE1DAD467B5"), ComVisible(false)]
    internal interface ISymUnmanagedReader
    {
        void GetDocument([MarshalAs(UnmanagedType.LPWStr)] string url, Guid language, Guid languageVendor, Guid documentType, [MarshalAs(UnmanagedType.Interface)] out ISymUnmanagedDocument retVal);
        void GetDocuments(int cDocs, out int pcDocs, [In, Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex=0)] ISymUnmanagedDocument[] pDocs);
        [PreserveSig]
        int GetUserEntryPoint(out SymbolToken EntryPoint);
        [PreserveSig]
        int GetMethod(SymbolToken methodToken, [MarshalAs(UnmanagedType.Interface)] out ISymUnmanagedMethod retVal);
        [PreserveSig]
        int GetMethodByVersion(SymbolToken methodToken, int version, [MarshalAs(UnmanagedType.Interface)] out ISymUnmanagedMethod retVal);
        void GetVariables(SymbolToken parent, int cVars, out int pcVars, [In, Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex=1)] ISymUnmanagedVariable[] vars);
        void GetGlobalVariables(int cVars, out int pcVars, [In, Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex=0)] ISymUnmanagedVariable[] vars);
        void GetMethodFromDocumentPosition(ISymUnmanagedDocument document, int line, int column, [MarshalAs(UnmanagedType.Interface)] out ISymUnmanagedMethod retVal);
        void GetSymAttribute(SymbolToken parent, [MarshalAs(UnmanagedType.LPWStr)] string name, int sizeBuffer, out int lengthBuffer, [In, Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex=2)] byte[] buffer);
        void GetNamespaces(int cNameSpaces, out int pcNameSpaces, [In, Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex=0)] ISymUnmanagedNamespace[] namespaces);
        void Initialize(IntPtr importer, [MarshalAs(UnmanagedType.LPWStr)] string filename, [MarshalAs(UnmanagedType.LPWStr)] string searchPath, IStream stream);
        void UpdateSymbolStore([MarshalAs(UnmanagedType.LPWStr)] string filename, IStream stream);
        void ReplaceSymbolStore([MarshalAs(UnmanagedType.LPWStr)] string filename, IStream stream);
        void GetSymbolStoreFileName(int cchName, out int pcchName, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder szName);
        void GetMethodsFromDocumentPosition(ISymUnmanagedDocument document, int line, int column, int cMethod, out int pcMethod, [In, Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex=3)] ISymUnmanagedMethod[] pRetVal);
        void GetDocumentVersion(ISymUnmanagedDocument pDoc, out int version, out bool pbCurrent);
        void GetMethodVersion(ISymUnmanagedMethod pMethod, out int version);
    }
}

